package com.augurit.gzcgwsp.printDoc.convert;

import java.util.ArrayList;
import java.util.List;

import org.dozer.DozerBeanMapper;

import com.augurit.gzcgwsp.printDoc.entity.YwPrintDoc;
import com.augurit.gzcgwsp.printDoc.web.form.YwPrintDocForm;

public class YwPrintDocConvertor {
    public static YwPrintDocForm convertVoToForm(YwPrintDoc entity) {
        if (entity == null) return null;
        YwPrintDocForm form = new YwPrintDocForm();
        
		form.setFileCode(entity.getFileCode());
		form.setId(entity.getId());
		form.setPath(entity.getPath());
		form.setTemplateCode(entity.getTemplateCode());
		form.setYwId(entity.getYwId());
		form.setCreatDate(entity.getCreatDate());
		form.setCreator(entity.getCreator());
		form.setTempdocId(entity.getTempdocId());
		form.setFileNum(entity.getFileNum());
        return form;
    }
    
    public static void convertFormToVo(YwPrintDocForm form, YwPrintDoc entity) {
        if (form == null) return;
        if (entity == null) entity = new YwPrintDoc();
        
        new DozerBeanMapper().map(form, entity);
    }
    
    public static List<YwPrintDocForm> convertVoListToFormList(List<YwPrintDoc> ywRqInstallentinfoList) {
        if(ywRqInstallentinfoList != null && ywRqInstallentinfoList.size() > 0) {
            List<YwPrintDocForm> ywRqInstallentinfoFormList = new ArrayList();
            for(int i=0; i<ywRqInstallentinfoList.size(); i++) {
                ywRqInstallentinfoFormList.add(convertVoToForm(ywRqInstallentinfoList.get(i)));
            }
            return ywRqInstallentinfoFormList;
        }
        return null;
    }
    
    public static List<YwPrintDoc> convertFormListToVoList(List<YwPrintDocForm> ywRqInstallentinfoFormList) {
        if(ywRqInstallentinfoFormList != null && ywRqInstallentinfoFormList.size() > 0) {
            List<YwPrintDoc> ywRqInstallentinfoList = new ArrayList();
            for(int i=0; i<ywRqInstallentinfoFormList.size(); i++) {
                YwPrintDoc ywPrintDoc = new YwPrintDoc();
                convertFormToVo(ywRqInstallentinfoFormList.get(i), ywPrintDoc);
                ywRqInstallentinfoList.add(ywPrintDoc);
            }
            return ywRqInstallentinfoList;
        }
        return null;
    }
}